/*
 * Zhz.net Inc.
 * Copyright (c) 2010 All Rights Reserved.
 */
package com.ceicei.project.dal.ibatis;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ceicei.project.dal.daointerface.CeiceiItemDAO;

// auto generated imports
import com.ceicei.project.dal.dataobject.CeiceiItemDO;
import org.springframework.dao.DataAccessException;
import java.util.List;
import com.ceicei.project.dal.dataobject.CeiceiItemDO;
import java.util.Map;
import java.util.HashMap;

/**
 * An ibatis based implementation of dao interface <tt>com.ceicei.project.dal.daointerface.CeiceiItemDAO</tt>.
 *
 * This file is generated by <tt>paygw-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>paygw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/biz/dal/src/conf/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/ceicei_items.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>paygw-dalgen</tt> 
 * to generate this file.
 *
 * @author Li Wei
 */
public class IbatisCeiceiItemDAO extends SqlMapClientDaoSupport implements CeiceiItemDAO {
	/**
	 *  Query DB table <tt>ceicei_items</tt> for records.
	 *
   	 *  <p>
   	 *  Description for this operation is<br>
   	 *  <tt></tt>
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select * from ceicei_items where (itemid = ?)</tt>
	 *
	 *	@param itemid
	 *	@return CeiceiItemDO
	 *	@throws DataAccessException
	 */	 
    public CeiceiItemDO getByItemId(int itemid) throws DataAccessException {
        Integer param = new Integer(itemid);

        return (CeiceiItemDO) getSqlMapClientTemplate().queryForObject("MS-CEICEI-ITEM-GET-BY-ITEM-ID", param);

    }

	/**
	 *  Query DB table <tt>ceicei_items</tt> for records.
	 *
   	 *  <p>
   	 *  Description for this operation is<br>
   	 *  <tt></tt>
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select * from ceicei_items</tt>
	 *
	 *	@return List<CeiceiItemDO>
	 *	@throws DataAccessException
	 */	 
    public List<CeiceiItemDO> getAllItem() throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-CEICEI-ITEM-GET-ALL-ITEM", null);

    }

	/**
	 *  Query DB table <tt>ceicei_items</tt> for records.
	 *
   	 *  <p>
   	 *  Description for this operation is<br>
   	 *  <tt></tt>
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select * from ceicei_items where (source = ?)</tt>
	 *
	 *	@param source
	 *	@return List<CeiceiItemDO>
	 *	@throws DataAccessException
	 */	 
    public List<CeiceiItemDO> getBySource(String source) throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-CEICEI-ITEM-GET-BY-SOURCE", source);

    }

	/**
	 *  Update DB table <tt>ceicei_items</tt>.
	 *
   	 *  <p>
   	 *  Description for this operation is<br>
   	 *  <tt></tt>
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>update ceicei_items set cur_price=? where (itemid = ?)</tt>
	 *
	 *	@param curPrice
	 *	@param itemid
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int updateCurPrice(float curPrice, int itemid) throws DataAccessException {
        Map param = new HashMap();

        param.put("curPrice", new Float(curPrice));
        param.put("itemid", new Integer(itemid));

        return getSqlMapClientTemplate().update("MS-CEICEI-ITEM-UPDATE-CUR-PRICE", param);
    }

}